<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>字典管理</title>
	<script type="text/javascript">
		$(document).ready(function() {
			layui.use('table', function(){
				let table = layui.table;
				table.init('layui-filter-table1',{
					escape : false
					,height: getLayuiTableHeight()
					,className: 'layui-table-custom'
					,done: function (res,curr,count){
					}
				});
			});
		});
	</script>
</head>
<body>
<div class="content">
	<sys:message content="${message}"/>
	<div class="card">
		<form:form id="searchForm" class="form-inline"
					   modelAttribute="dict" method="post"
					   action="${ctxAdmin}/sys/dict/">
				<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
				<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
				<div class="input-group input-group-sm">
					<div class="input-group-prepend">
						<span class="input-group-text">类别</span>
					</div>
					<form:select id="category" path="category" data-width="163px" data-container-css-class="select-sm">
						<form:option value="" label=""/>
						<form:options items="${categoryList}" htmlEscape="false"/>
					</form:select>
				</div>
				<div class="input-group input-group-sm">
					<div class="input-group-prepend">
						<span class="input-group-text">类型</span>
					</div>
					<form:select id="type" path="type" data-width="163px" data-container-css-class="select-sm">
						<form:option value="" label=""/>
						<form:options items="${typeList}" htmlEscape="false"/>
					</form:select>
				</div>
				<div class="input-group input-group-sm">
					<div class="input-group-prepend">
						<span class="input-group-text">描述</span>
					</div>
					<form:input path="description" htmlEscape="false" maxlength="100" class="form-control"/>
				</div>
				<div class="btn-group btn-group-sm">
					<button id="btnSubmit" type="submit" class="btn btn-primary " onclick="return page();">查询</button>
					<button id="btnReset" type="button" class="btn btn-success" onclick="resetForm();page();">重置</button>
				</div>
		</form:form>
		<div id="optButtonGroup" class="p-1">
			<shiro:hasPermission name="sys:dict:edit">
				<button class="btn btn-sm btn-outline-primary" onclick="popupLayerLeft('新增',$(this).data('url'))"
						data-url="${ctxAdmin}/sys/dict/form"><i class="icon-database-add mr-2"></i>新增</button>
				<button class="btn btn-sm btn-outline-primary" onclick="confirmUpdate(this,'layui-table-id1','更新数据')"
						data-url="${ctxAdmin}/sys/dict/form?id="><i class="icon-database-edit2 mr-2"></i>修改</button>
				<button class="btn btn-sm btn-outline-danger" onclick="batchConfirmOperation(this,'layui-table-id1')"
						data-url="${ctxAdmin}/sys/dict/delete?ids="><i class="icon-database-remove mr-2"></i>删除</button>
			</shiro:hasPermission>
		</div>
		<table id="layui-table-id1" lay-filter="layui-filter-table1" style="display: none;">
			<thead>
			<tr>
				<th lay-data="{field:'numbers',type: 'numbers',align:'center',width:40, fixed: 'left'}">#</th>
				<th lay-data="{field:'checkbox',type: 'checkbox', fixed: 'left'}"></th>
				<th lay-data="{field:'id',hide:true}">ID</th>
				<th lay-data="{field:'a.description'}">描述</th>
				<th lay-data="{field:'a.type'}">类型</th>
				<th lay-data="{field:'a.label'}">标签</th>
				<th lay-data="{field:'a.value',width:100}">键值</th>
				<th lay-data="{field:'a.sort',align:'center',width:40}">排序</th>
				<th lay-data="{field:'opt',align:'center',width: 200,fixed:'right'}">操作</th>
			</tr>
			</thead>
			<tbody>
			<c:forEach items="${page.list}" var="dict">
				<tr>
					<td></td>
					<td></td>
					<td>${dict.id}</td>
					<td>${dict.description}</td>
					<td><a href="javascript:" onclick="$('#type').val('${dict.type}');$('#searchForm').submit();return false;">${dict.type}</a></td>
					<td>${dict.label}</td>
					<td>${dict.value}</td>
					<td>${dict.sort}</td>
					<shiro:hasPermission name="sys:dict:edit">
						<td>
							<a class="btn btn-outline alpha-primary text-primary" onclick="popupLayerLeft('添加键值',$(this).data('url'))"
							   data-url="${ctxAdmin}/sys/dict/form?type=${dict.type}&sort=${dict.sort+10}&description=${dict.description}&category=${dict.category}">添加键值</a>
						</td>
					</shiro:hasPermission>
				</tr>
			</c:forEach>
			</tbody>
		</table>
		<sys:laypage page="${page}"/>
	</div>
</div>
</body>
</html>